import { configBarStackSeries } from './config.js'
export default {
  legend: {
    type: 'scroll',
    bottom: 0
  },
  grid: { left: '3%', right: '3%', top: '10%', bottom: '12%', containLabel: true },
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'shadow',
      axis: 'auto'
    },
    formatter: function (params) {
      let total = 0
      params[0].data.forEach((item, index) => {
        if (index !== 0) {
          total += item
        }
      })
      let str = '<div style="display: flex;flex-direction: column;">' + params[0].name + '<br/>'
      params.forEach((item, index) => {
        str +=
          '<div style="display: flex;justify-content: space-between;margin-top:4px;"><span style="margin-right:20px;">' +
          item.marker +
          item.seriesName +
          '</span><b>' +
          item.data[index + 1] +
          '(' +
          ((item.data[index + 1] / total) * 100).toFixed(2) +
          '%)</b></div>'
      })
      return str + '</div>'
    },
    confine: true
  },
  xAxis: {
    type: 'category'
  },
  yAxis: {
    type: 'value',
    minInterval: 1
  },
  series: configBarStackSeries()
}
